// 例子41

{
    let NewPoint = class Point {
        constructor(x, y) {
            this.x = x;
            this.y = y;
        }

        getClassName() {
            return Point.name
        }
    }

    let p1 = new NewPoint(1, 2);
    console.log(p1, p1.getClassName()); // Point {x: 1, y: 2} "Point"

    try {
        let p2 = new Point(1, 2); // Uncaught ReferenceError: Point is not defined
        console.log(p2, p2.getClassName());
    } catch(e) {
        console.error(e)
    }

}

console.log('----------------------------------');

{
    let Point = class {
        constructor(x, y) {
            this.x = x;
            this.y = y;
        }

        getX() {
            return this.x;
        }

        getY() {
            return this.y;
        }
    }

    let p = new Point(1, 2);
    console.log(p, p.getX(), p.getY()); // Point {x: 1, y: 2} 1 2
}